/*
    Android UIML

	Copyright (C) 2010  Bram Goffings (bramgoffings@gmail.com)

	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU Lesser General Public License
	as published by the Free Software Foundation; either version 2.1
	of	the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Lesser General Public License for more details.

	You should have received a copy of the GNU Lesser General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

package uiml.android.elements;

import java.util.ArrayList;

import org.w3c.dom.Element;

import uiml.android.elements.peers.Peer;
import uiml.android.template.Template;

/**
 * 
 * @author bram
 */
public class Uiml extends UimlElement {

	private ArrayList<Peer> peers;
	
	private Head head;
	private Interface interf;
	
	/**
	 * 
	 * @param node
	 */
	public Uiml(Element node) {
		super(node);
		System.out.println("Uiml element aangemaakt");
		load();
	}

	/**
	 * 
	 */
	public void load() {
		peers = new ArrayList<Peer>();
		process();
	}

	/**
	 * 
	 */
	@Override
	public void processElement(Element elem) {
		
		if(elem.getTagName().equals(Head.IAM))
			setHead(new Head(elem));
		else if(elem.getTagName().equals(Peer.IAM))
			addPeer(new Peer(elem));
		else if(elem.getTagName().equals(Interface.IAM))
			setInterf(new Interface(elem));
		else if(elem.getTagName().equals(Template.IAM))
			new Template(elem);
	}
	
	/**
	 * Adds a peer
	 * 
	 * @param peer the peer that will be added
	 */
	private void addPeer(Peer peer) {
		peers.add(peer);
	}
	
	/**
	 * Get the list of peers
	 * 
	 * @return a list containing the peers
	 */
	public ArrayList<Peer> getPeers() {
		return peers;
	}

	/**
	 * 
	 * @param head
	 */
	public void setHead(Head head) {
		this.head = head;
	}

	/**
	 * 
	 * @return
	 */
	public Head getHead() {
		return head;
	}

	/**
	 * 
	 * @param interf
	 */
	public void setInterf(Interface interf) {
		this.interf = interf;
	}

	/**
	 * 
	 * @return
	 */
	public Interface getInterf() {
		return interf;
	}
}
